/*
 * @Author: 天桥底下说书的 179946422@qq.com
 * @Date: 2024-05-14 22:48:29
 * @LastEditors: 天桥底下说书的 179946422@qq.com
 * @LastEditTime: 2024-05-15 00:04:55
 * @FilePath: \esp32-assistant\lib\MyLed\MyLed.cpp
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
#include <MyLed.h>
#include <MyLog.h>

void led_setup()
{
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
}

// 控制指示灯闪烁
void blink(int ledPin)
{
    Log.infoln("指示灯闪烁...");
    pinMode(ledPin, OUTPUT);
    for (int i = 0; i < 2; i++)
    {
        digitalWrite(ledPin, HIGH);
        vTaskDelay(100 / portTICK_PERIOD_MS);
        digitalWrite(ledPin, LOW);
        vTaskDelay(100 / portTICK_PERIOD_MS);
    }
}

// 控制指示灯闪烁
void blink()
{
    Log.infoln("指示灯闪烁...");
    digitalWrite(led3, HIGH);
    vTaskDelay(100 / portTICK_PERIOD_MS);
    digitalWrite(led3, LOW);
    vTaskDelay(100 / portTICK_PERIOD_MS);
}

// 控制指示灯状态
void ledStatus(int ledPin, bool status)
{
    Log.infoln("更改指示灯状态");
    pinMode(ledPin, OUTPUT);
    if (status)
    {
        digitalWrite(ledPin, HIGH);
    }
    else
    {
        digitalWrite(ledPin, LOW);
    }
}